export default function nestTokens(tokens) {
    let nestedTokens = []
    let cellector = nestedTokens
    let childs = []

    let token
    for(let i = 0; i < tokens.length; i++) {
        token = tokens[i]

        switch (token[0]) {
            case '#':
                cellector.push(token)
                cellector = token[2] = []
                childs.push(token[2])
                break;
            case '/':
                childs.pop()
                cellector = childs.length ? childs[childs.length - 1] : nestedTokens
                break;
            default:
                cellector.push(token)
                break;
        }
    }

    return nestedTokens
}